<?
class ListProvinceForm extends Form{
	function ListProvinceForm(){
		Form::Form('ListProvinceForm');
	}
	
	function on_submit(){
		if(Url::get('cmd')=='delete'){
			$selected_ids=Url::get('selected_ids');
			
			if($selected_ids){
				$ids=implode(',',$selected_ids);
				
				if($ids){
					DB::delete('province', "id IN(".$ids.")");
				}
			}
		}
		Url::redirect_current();
	}
	
	function draw(){
		global $display;
		$this->beginForm(false,"post",false,Url::build_current());
		
		$item_per_page = 30;
		$total_row = DB::fetch('SELECT count(*) AS total_row FROM `province` limit 0,1','total_row',0);
		
		$paging='';
		$items=array();
		if($total_row){
			$limit='';
			
			$paging=AZPagging::pagingSE($limit,$total_row,$item_per_page,10,'page_no',true);
			
			$sql="SELECT * FROM province ORDER BY id ".$limit;
			$re=DB::query($sql);
			
			
			if($re){
				while ($row=mysql_fetch_assoc($re)) {
					$area=array(1=>'Bắc',2=>'Trung',3=>'Nam');
					$status=array('SHOW'=>'Hiện','HIDE'=>'<font color=red>Ẩn</font>','HOME'=>'HOME');
					
					$row['area']=$area[$row['area']];
					$row['status']=$status[$row['status']];
					$items[$row['id']]=$row;
					$items[$row['id']]=$row;
				}
			}
		}
		
		$display->add('hover',AZLib::mouse_hover('#F7F7F7',true));
		$display->add('items',$items);
		$display->add('paging',$paging);
		$display->add('total_row',$total_row);
		$display->output('list');
		$this->endForm();
	}
}
?>